/*
 * @Author: yuzc 
 * @Date: 2020-08-12 14:24:28 
 * @Last Modified by: yuzc
 * @Last Modified time: 2020-08-12 14:39:07
 * 
 * 
 * 渐变圆角按钮
 * text 按钮为文字内容
 * top 为按钮距离顶部控件的高度
 * 
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class GradientButton extends StatefulWidget {
  final String text;
  final double top;
  final VoidCallback onTap;

  const GradientButton({Key key, @required this.text, this.top = 0, this.onTap})
      : super(key: key);

  @override
  _GradientButtonState createState() => _GradientButtonState();
}

class _GradientButtonState extends State<GradientButton> {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(
          right: (144 / 2).w, left: (144 / 2).w, top: (widget.top).h),
      child: Material(
        borderRadius: BorderRadius.circular(100),
        child: Ink(
          decoration: BoxDecoration(
            gradient: const LinearGradient(colors: [
              Color.fromRGBO(0, 197, 135, 1),
              Color.fromRGBO(0, 158, 100, 1),
            ]),
            borderRadius: BorderRadius.circular(100),
          ),
          child: InkWell(
            borderRadius: BorderRadius.circular(100),
            onTap: widget.onTap,
            child: Container(
              alignment: Alignment.center,
              width: double.infinity,
              height: (80 / 2).h,
              child: Text(widget.text,
                  style: new TextStyle(
                      fontSize: (34 / 2).sp, color: Colors.white)),
            ),
          ),
        ),
      ),
    );
  }
}
